﻿@model AuthorizationCode
@{
    ViewData["Title"] = Model.tenantName;
    var code = Context.Request.Query["code"];
    var state = Context.Request.Query["state"];
    var client = ViewBag.client as OAuthApp.Data.App;
    var redirect_uri = new Uri(Model.redirect_uri);
    var cancelUri = redirect_uri.Scheme + "://" + redirect_uri.Authority + redirect_uri.AbsolutePath;
}
@if (Model != null)
{
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12 col-md-4 offset-md-4 d-flex align-items-start justify-content-center border border-top-0 border-bottom-0"
             style="height: 100vh;">
            <div style="width:80%" class="mt-5">
                <div class="d-flex text-center">
                    <div class="w-50">
                        <div>
                            <img src="@Model.userAvatar" class="shadow-sm border border-2 p-1 rounded-circle" width="68px" onerror="this.src='/assets/user_default.png'" />
                        </div>
                        <h2 class="mt-3 mb-2">
                            @Model.userName
                        </h2>
                        <form asp-action="SignOut" asp-controller="OAuth">
                            <input type="hidden" name="code" value="@code" />
                            <button class="btn btn-white">切换账号</button>
                        </form>
                    </div>
                    <div class="d-flex align-items-center justify-content-center">
                        <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-arrows-right-left" viewBox="0 0 24 24" stroke-width="1" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
                            <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                            <line x1="21" y1="7" x2="3" y2="7"></line>
                            <path d="M18 10l3 -3l-3 -3"></path>
                            <path d="M6 20l-3 -3l3 -3"></path>
                            <line x1="3" y1="17" x2="21" y2="17"></line>
                        </svg>
                    </div>
                    <div class="w-50">
                        <div>
                            <img src="@client.Logo" class="shadow-sm border border-2 p-1 rounded-circle" width="68px" onerror="this.src='/assets/app_default.png'" />
                        </div>
                        <div class="my-3">
                            <h1>@client.Name</h1>
                            <p class="mt-2">@client.Website</p>
                        </div>
                    </div>
                </div>

                <div class="hr-text hr-text-center hr-text-spaceless my-4 fs-5 fw-normal">
                    申请以下权限
                </div>

                <div class="my-4 border p-1">
                    <div class="list-group list-group-flush">
                        @foreach (var s in Model.scope.Split(' '))
                        {
                            <a href="#" class="list-group-item list-group-item-action">@s</a>
                        }
                    </div>
                </div>
                <form action="/OAuth/ConsentPost" method="post">
                    <input type="hidden" name="code" value="@code" />
                    <input type="hidden" name="state" value="@state" />
                    <div class="d-flex flex-column">
                        <button type="submit" class="btn btn-indigo">确认授权</button>
                        <a href="@cancelUri" class="btn btn-white my-3">撤销</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
        }
